﻿using System.Collections.Generic;
using Newtonsoft.Json.Linq;

namespace Amba.ULogin.Services
{

    public class ULoginUser
    {
        private JObject _jsonUser;

        public IEnumerable<JProperty> Properties
        {
            get
            {
                return _jsonUser.Properties();
            }
        }

        public string FirstName
        {
            get { return GetStringValue("first_name"); }
        }

        public bool IsVerifiedEmail
        {
            get { return GetStringValue("verified_email") == "1"; }
        }

        public string LastName
        {
            get { return GetStringValue("last_name"); }
        }

        public string Email
        {
            get { return GetStringValue("email"); }
        }

        public string Uid
        {
            get { return GetStringValue("uid"); }
        }

        public string Network
        {
            get { return GetStringValue("network"); }
        }

        public string Profile
        {
            get { return GetStringValue("profile"); }
        }

        public string Identity
        {
            get { return GetStringValue("identity"); }
        }

        public string Nickname
        {
            get { return GetStringValue("nickname"); }
        }

        public string BDate
        {
            get { return GetStringValue("bdate"); }
        }

        public string ResponseData { get; set; }

        public ULoginUser(string s)
        {
            _jsonUser = JObject.Parse(s);
            ResponseData = s;
        }

        public string GetStringValue(string key)
        {
            return _jsonUser.Value<string>(key);
        }

        public string Phone
        {
            get { return GetStringValue("phone"); }
        }

        public string Country
        {
            get { return GetStringValue("country"); }
        }

        public string City
        {
            get { return GetStringValue("city"); }
        }

        public string Sex
        {
            get { return GetStringValue("sex"); }
        }

        public string Photo { get { return GetStringValue("photo"); } }

        public string PhotoBig { get { return GetStringValue("photo_big"); } }
    }

}